﻿using System;
using System.Diagnostics;
using UnityEngine;

class TimeHelper
{
    public static long ConvertDateTimeToLong(DateTime dt)
    {
        return (long)(dt - TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1, 0, 0, 0), TimeZoneInfo.Local)).TotalSeconds;
    }

    public static DateTime ConvertLongToDateTime(long timestamp)
    {
        return TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1, 0, 0, 0), TimeZoneInfo.Local).AddSeconds(timestamp);
    }

    public static bool IsTimeArrival(float startTime, float endTime)
    {
        return (Time.realtimeSinceStartup - startTime) >= endTime;
    }

    public static bool IsSameDay(long time)
    {
        return IsSameDay(ConvertLongToDateTime(time));
    }

    public static bool IsSameDay(DateTime dateTime)
    {
        return (DateTime.Now.Date-dateTime.Date).Days!=0;
    }
}